<template>
  <div
    :class="['right-container', showRight && 'show']"
    :style="{ width: dragController.rightWidth + 'px' }"
    @click.self="toggleShow"
  >
    <div style="width: 100%; overflow: hidden">
      <el-tabs v-model="activeName">
        <el-tab-pane label="组件属性" name="widgetProps">
          <div class="right-content">
            <CreatePropForm :widgetProps="widgetProps" :widgetPropDescribe="widgetPropDescribe" />
          </div>
        </el-tab-pane>
        <el-tab-pane label="表单属性" name="formProps">xxx</el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import CreatePropForm from "./CreatePropForm.vue";
export default {
  name: "Right",
  components: {
    CreatePropForm
  },
  props: {
    dragController: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      showRight: true,
      activeName: "widgetProps",
    };
  },
  computed: {
    widgetProps() {
      return this.dragController.propsController.getCurrentControlProps() || {};
    },
    widgetPropDescribe() {
      return this.dragController.propsController.getCurrentControlWidgetPropDescribe() || {};
    },
  },
  methods: {
    toggleShow() {
      this.showRight = !this.showRight;
      this.dragController.rightWidth = this.showRight ? 360 : 0;
    },
  },
};
</script>

<style lang="scss" scoped>
.right-container {
  box-shadow: 0 0 12px 1px #f1f1f1;
  box-sizing: border-box;
  position: relative;
  pointer-events: none;
}
.right-container::before {
  content: "<";
  width: 24px;
  height: 72px;
  line-height: 72px;
  text-align: center;
  border-radius: 8px 0 0 8px;
  box-shadow: 1px 0 12px 0 #ccc;
  position: absolute;
  top: 50%;
  left: -26px;
  transform: translateY(-50%);
  cursor: pointer;
  pointer-events: auto;
}
.right-container.show::before {
  content: ">";
}
.right-container * {
  pointer-events: auto;
}
.right-content {
  height: calc(100vh - 80px);
  margin: 15px;
  overflow-y: auto;

  ::v-deep .el-form-item {
    margin-bottom: 8px;
  }
}
</style>